package com.caowei.weicimpress.weicimpress;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * Created by caoweiPc on 2014/8/26.
 */
public class NotifyChangeBroadcastReceiver extends BroadcastReceiver {
    private TaskFragment taskFragment;
    private SysFileFragment sysFileFragment;
    private CompressFileFragment compressFileFragment;
    public SysFileFragment getSysFileFragment() {
        return sysFileFragment;
    }

    public void setSysFileFragment(SysFileFragment sysFileFragment) {
        this.sysFileFragment = sysFileFragment;
    }

    public TaskFragment getTaskFragment() {
        return taskFragment;
    }

    public void setTaskFragment(TaskFragment taskFragment) {
        this.taskFragment = taskFragment;
    }

    public CompressFileFragment getCompressFileFragment() {
        return compressFileFragment;
    }

    public void setCompressFileFragment(CompressFileFragment compressFileFragment) {
        this.compressFileFragment = compressFileFragment;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        String action=intent.getAction();
        if(action.equals(Utils.NOTIFYTASKCHANGE_ACTION)){
            taskFragment.refresh();
        }else if(action.equals(Utils.NOTIFYFILESYSTEMCHANGEINCURRENTDIR_ACTION)){
            String currentPath=intent.getStringExtra("currentPath");
            sysFileFragment.refreshFromPath(currentPath);
        }else if(action.equals(Utils.NOTIFYCOMPRESSSYSTEMCHANGE_ACTION)){
            compressFileFragment.refresh();
        }
    }


}
